import { ConfigProvider } from "ant-design-vue";
import { RouterView } from "vue-router";
import { AntLanguage } from "@/lang/AntDesignLang";
import { getLanguage } from "./lang/tools";
import.meta.glob(["@/config/browser"], {
  eager: true,
});
// @ts-ignore
import { getmark } from "@/utils/watermark";
const { watermark } = getmark();
const defaultAntLang = ref<string>("");
const setPageLang = (lang: string) => {
  defaultAntLang.value = lang;
  $dayjs.locale(lang);
  return lang;
};
export default defineComponent({
  setup() {
    const localeValue = getLanguage();
    setPageLang(localeValue);
    provide("setPageLang", setPageLang);
    onMounted(() => watermark("Coin Cupid"));
    onUnmounted(() => watermark(""));
    return () => (
      <ConfigProvider
        locale={AntLanguage[defaultAntLang.value]}
        prefix-cls="im"
      >
        <RouterView>
          {{
            default: ({ Component }: { Component: any }) => <>{h(Component)}</>,
          }}
        </RouterView>
      </ConfigProvider>
    );
  },
});
